package avicit.bdp.dms.prm.rest;

import avicit.bdp.common.service.dto.CommonCodeDTO;
import avicit.bdp.common.service.service.CommonCodeService;
import avicit.platform6.core.rest.msg.ResponseMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 通用代码管理REST接口
 *
 * @author felix
 */
@RestController
@Api(tags = "通用代码管理REST接口")
@RequestMapping("/api/bdp/dms/prm/commonCode")
public class CommonCodeRest {

    @Autowired
    private CommonCodeService commonCodeService;

    /**
     * 查询通用代码
     */
    @ApiOperation(value = "查询通用代码")
    @ApiImplicitParam(value = "分类类型", name = "type", dataType = "String")
    @GetMapping("/findCommonCode")
    public ResponseMsg<List<CommonCodeDTO>> findCommonType(@RequestParam String type) {
        ResponseMsg<List<CommonCodeDTO>> responseMsg = new ResponseMsg<>();
        List<CommonCodeDTO> result = commonCodeService.findCommonCode(type);
        responseMsg.setResponseBody(result);
        return responseMsg;
    }

}
